// Copyright (2017) Baidu Inc. All rights reserveed.
/**
 * File: lightduer_alarm.h
 * Auth: Gang Chen (chengang12@baidu.com)
 * Desc: Light duer alarm APIs.
 */

#ifndef BAIDU_IOT_TINYDU_IOT_OS_SRC_ALARM_BAIDU_ALARM_H
#define BAIDU_IOT_TINYDU_IOT_OS_SRC_ALARM_BAIDU_ALARM_H

namespace duer {

/**
 * The callback to set alarm
 * PARAM:
 * @param[in] id: it is needed when report alarm event
 * @param[in] token: the alarm token, it is the unique identification of an alarm
 * @param[in] url: the alerting tone of the alarm
 * @param[in] time: the time stamp of the alarm, it's the seconds from 1970-01-01 to now.
 * @return: 0 when success, negative value when failed.
 */
typedef int (*duer_set_alarm_func)(const int id,
                                   const char *token,
                                   const char *url,
                                   const int time);

/**
 * The callback to delete alarm
 * PARAM:
 * @param[in] id: it is needed when report alarm event
 * @param[in] token: the alarm token, it is the unique identification of an alarm
 * @return: 0 when success, negative value when failed.
 */
typedef int (*duer_delete_alarm_func)(const int id, const char *token);

typedef enum {
    SET_ALERT_SUCCESS,
    SET_ALERT_FAIL,
    DELETE_ALERT_SUCCESS,
    DELETE_ALERT_FAIL,
    ALERT_START,
    ALERT_STOP,
} alarm_event_type;

/**
 * Report alarm event
 * PARAM:
 * @param[in] id: the "id" itme is contained in set/delete alarm directive
 * @param[in] type: event type, refer to alarm_event_type.
 * @return: 0 when success, negative value when failed.
 */
int duer_report_alarm_event(int id, const char *token, alarm_event_type type);

/**
 * Initalize alarm function
 * PARAM:
 * @param[in] set_alarm_cb: callback to set alarm
 * @param[in] delete_alarm_cb: callback to delete alarm
 * @return: none
 */
void duer_alarm_initialize(duer_set_alarm_func set_alarm_cb,
                           duer_delete_alarm_func delete_alarm_cb);

}

#endif/*BAIDU_IOT_TINYDU_IOT_OS_SRC_ALARM_BAIDU_ALARM_H*/

